package com.org.dao.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Repository;

import com.org.IbatisBaseDao;
import com.org.dao.IProductParameterDao;
import com.org.model.Parameter;
import com.org.model.ProductCategory;
import com.org.model.Qqemail;

@Repository
@SuppressWarnings("all")
public class ProductParameterDaoImpl extends IbatisBaseDao implements IProductParameterDao {
	
	private Logger logger=Logger.getLogger(ProductParameterDaoImpl.class);
	
	@Override
	public void deleteProductParameterById(String primaryKey) throws Exception {
		sqlMapClient.delete("findProductParameterById", primaryKey);
	}

	@Override
	public boolean getIsExistParameter(String parameter) throws Exception {
		boolean flag=Boolean.FALSE;
		List<Parameter> lists=sqlMapClient.queryForList("findIsExistParameter", parameter);
		if(lists!=null&&lists.size()>0){
			return true;
		}else{
			return flag;
		}  
	}

	@Override
	public Parameter getProductParameterById(String primaryKey)
			throws Exception {
		Parameter obj=(Parameter)sqlMapClient.queryForObject("findParameterById", primaryKey);
		return obj;
	}

	@Override
	public Map<String, Object> getProductParameterLists(Map<String, Object> params) throws Exception {
		Map<String, Object> result;
		try {
			result = new HashMap<String, Object>();
			Integer total = (Integer) sqlMapClient.queryForObject("findProductParameterCount", params);
			List queryForList = sqlMapClient.queryForList("findProductParameterLists", params);
			List<Map<String, Object>> list = queryForList;
			result.put("total", total);
			result.put("list", list);
			return result;
		} catch (Exception e) {
			logger.info("find getProductParameterLists"+ e.getMessage());
			e.printStackTrace();
		}
		return null;
	
	}

	@Override
	public void insertProductParameter(Parameter entity) throws Exception {
		sqlMapClient.insert("insertProductParameter", entity);
	}

	@Override
	public void updateProductParameterById(Parameter entity) throws Exception {
		sqlMapClient.update("updateProductParameter", entity);
	
	}

}
